package ddpush

import (
	"xlq-demo/library/config"
	"fmt"
	"encoding/json"
	"xlq-demo/library/util"
)

//钉钉推送
type ErrorPushIn struct {
	File string `json:"file"`
	Line int `json:"line"`
	Content string `json:"content"`
}
func ErrorPush(in *ErrorPushIn) {
	url := config.Config.Dpush.ErrorRobot

	content := "异常报警\n" +
		"异常项目："+config.Config.Base.Name + "\n"+
		"异常环境：" + config.Config.Base.Env + "\n" +
		"异常级别：ERROR\n" +
		"异常文件：" + in.File + "\n" +
		"异常行数：" + fmt.Sprintf("%d",in.Line) + "\n" +
		"异常消息：" + in.Content

	msg := pushMsg {
		Msgtype: "text",
		Text: pushMsgText{
			Content: content,
		},
	}

	msgBys,_ := json.Marshal(msg)

	util.HttpRequest("POST",url,msgBys,map[string]string{
		"Content-Type": "application/json",
	})

}




